import request from '@/utils/request'
import { camelCaseObject } from '@/libs/object'

const AUTH_PREFIX_V1 = `/api/v1/ticket`

export function getTicketOrderList(params) {
  return request.get(`${AUTH_PREFIX_V1}/orders`, { params }).then(res => camelCaseObject(res))
}

export function getTicketOrderListByPage(params) {
  return request.get(`${AUTH_PREFIX_V1}/orders/page`, { params }).then(res => camelCaseObject(res))
}

export function getTicketOrder(orderId) {
  return request.get(`${AUTH_PREFIX_V1}/orders/${orderId}`).then(res => camelCaseObject(res))
}

export function createTicketOrder(params) {
  return request.post(`${AUTH_PREFIX_V1}/orders`, params).then(res => camelCaseObject(res))
}

export function updateTicketOrder(orderId, params) {
  return request.put(`${AUTH_PREFIX_V1}/orders/${orderId}`, params).then(res => camelCaseObject(res))
}

export function executeTicketOrder(orderId, params) {
  return request.put(`${AUTH_PREFIX_V1}/orders/${orderId}/execute`, params).then(res => camelCaseObject(res))
}

export function deleteTicketOrder(orderId) {
  return request.delete(`${AUTH_PREFIX_V1}/orders/${orderId}`).then(res => camelCaseObject(res))
}

export function goinceptionCheckTicketOrder(params) {
  return request.post(`${AUTH_PREFIX_V1}/orders/goinception_check`, params).then(res => camelCaseObject(res))
}
